﻿/*
 * KLF Headless Browser
 * Written by Kris Oye <kristianoye@gmail.com>
 * Copyright (C) 2011-2012.  All rights reserved.
 */
namespace KLF.Lib.Browser.DOM.CSS.SAC.Selectors
{
    #region Using Statements

    using KLF.Lib.Browser.DOM.HTML;
    using System.Collections.Generic;

    #endregion

    /// <summary>
    /// Returns true if any of the selectors match the target element.
    /// </summary>
    public class AndSelector : Selector
    {
        public AndSelector(IEnumerable<Selector> _source)
        {
            Selectors = new List<Selector>(_source);
        }

        internal List<Selector> Selectors { get; set; }

        public override bool Matches(HTMLElement e)
        {
            foreach (Selector s in Selectors)
            {
                if (!s.Matches(e))
                    return false;
            }
            return true;
        }
    }
}
